package com.biz.jobs;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import com.biz.executor.TestExecutor;
import com.biz.utils.SpringApplicationContextHolder;

public class TestQuartzJob implements Job {
	 private static Logger log = LoggerFactory.getLogger(TestQuartzJob.class);
	 
		
	 public void execute(JobExecutionContext context)throws JobExecutionException{
	        log.info("test任务启动...");
	        try {
	        	System.out.println("=================test开始了===============");
	        	TestExecutor testExecutor = (TestExecutor)SpringApplicationContextHolder.getBean(TestExecutor.class);	        	
	        	ThreadPoolTaskExecutor threadPoolTaskExecutor =(ThreadPoolTaskExecutor) SpringApplicationContextHolder.getBean(ThreadPoolTaskExecutor.class);
	    		threadPoolTaskExecutor.execute(testExecutor);
	    		System.out.println("=================test结束了===============");
			} catch (Exception e) {
				e.printStackTrace();
				log.info("test任务启动失败...");
			}
	       
	        log.info("test任务结束...");
	         
	    }

}
